package service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import cn.yunhe.Dao.IUserDao;
import cn.yunhe.model.User;
import cn.yunhe.util.SqlSessionFactoryUtil;

public class UserService {

	  SqlSession session =SqlSessionFactoryUtil.getSqlSession();
	  IUserDao userDao =session.getMapper(IUserDao.class);
	 
	  public User login(String name, String password) {
		
		
		
		Map<String, String> map=new HashMap<String, String> ();
		map.put("username", name);
		map.put("password", password);
		User user = userDao.login(map);
		
		return user;
		
	}
	 
	 public int getCount() {
		 return userDao.getCount();
		 
	 }
	 
	 public List<User> getUserByPage(int pageIndex, int pageSize){
		 pageIndex=(pageIndex-1)*pageSize;
		 return userDao.getUserByPage(pageIndex, pageSize);
		 
	 }
	 
}
